package com.ym.soso.service.impl;

import com.ym.core.shiro.ShiroUtil;
import com.ym.core.utils.tkmybatis.BaseSVImpl;
import com.ym.medical.enums.CodeRuleEnum;
import com.ym.medical.service.ISysCodeRuleSV;
import com.ym.soso.dao.AedInfoDao;
import com.ym.soso.domain.entity.AedInfoEntity;
import com.ym.soso.domain.param.AedInfoQueryParam;
import com.ym.soso.domain.param.AedInfoUpdateParam;
import com.ym.soso.domain.vo.AedInfoListPcVO;
import com.ym.soso.service.IAedInfoSV;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * AED信息Service业务层处理
 *
 * @author ym
 * @date 2020-08-28
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class AedInfoSVImpl extends BaseSVImpl<AedInfoEntity, AedInfoDao> implements IAedInfoSV {

	@Autowired
	private ISysCodeRuleSV sysCodeRuleSV;

	/**
	 * 查询AED信息列表
	 *
	 * @param queryParam AED信息 查询参数
	 * @return AED信息
	 */
	@Override
	public List<AedInfoListPcVO> selectListPC(AedInfoQueryParam queryParam) {
		List<AedInfoListPcVO> aedInfos = mapper.selectListPC(queryParam);
		return aedInfos;
	}

	/**
	 * 新增AED信息
	 *
	 * @param updateParam AED信息 新增参数
	 * @return 结果
	 */
	@Override
	public Long insertPC(AedInfoUpdateParam updateParam) {
		AedInfoEntity update = updateParam.covert();
		String code = sysCodeRuleSV.createCode(CodeRuleEnum.AED);
		update.setTheCode(code);
		update.setCreSb(ShiroUtil.getLoginId());
		this.insert(update);
		return update.getId();
	}

	/**
	 * 修改AED信息
	 *
	 * @param updateParam AED信息 修改参数
	 * @return 结果
	 */
	@Override
	public int updateByIdPC(AedInfoUpdateParam updateParam) {
		AedInfoEntity update = updateParam.covert();
		update.setUptSb(ShiroUtil.getLoginId());
		int result = this.updateById(update);
		return result;
	}
}
